import 'package:aio/aio.dart';
import 'package:flutter/material.dart';
import 'package:app/generated/app_strings.dart';
import 'package:app/src/http/bean/wroks/contract_bean.dart';
import 'package:app/src/http/bean/ywx_limit.dart';
import 'package:app/src/ui/app_ui.dart';
import 'package:app/src/ui/route/works/public/review_list.dart';

import '../../../../http/bean/works_2023/commission_bean.dart';
import '../../../../http/bean/worksdo/material_requisition_bean.dart';
import '../../../../manager/ywx_manager.dart';

///公用列表内容
class ContentList {
  ///fixme 审核列表
  static Widget ywxItem(
      BuildContext context, YwxItem? item, ContractCopyInfo data,
      {List<ContractCopyInfo>? datas = null}) {
    if (item?.ReviewType == ReviewType.Order) {
      //订单审核
      return _order(context, data);
    } else if (item?.ReviewType == ReviewType.Auditaddress) {
      //送货地址审核
      return _auditaddress(context, data);
    } else if (item?.ReviewType == ReviewType.ContractOem) {
      //合同特殊设置审核
      return _contractOem(context, data);
    } else if (item?.ReviewType == ReviewType.OrderDJchek) {
      //冻结解冻审核
      return _orderDJchek(context, data);
    } else if (item?.ReviewType == ReviewType.OrdersChangeFactory) {
      //工厂更换审核
      return _ordersChangeFactory(context, data);
    } else if (item?.ReviewType == ReviewType.DeliveryNotice) {
      //发货审核
      return _deliveryNotice(context, data);
    } else if (item?.ReviewType == ReviewType.PayFreeGoodReturn) {
      //退货审核
      return _payFreeGoodReturn(context, data);
    } else if (item?.ReviewType == ReviewType.ReceiptApply) {
      //开票审核
      return _receiptApply(context, data);
    } else if (item?.ReviewType == ReviewType.Paynotice) {
      //确认收款
      return _paynotice(context, data);
    } else if (item?.ReviewType == ReviewType.PayFree) {
      //免款审核
      return _payFree(context, data);
    } else if (item?.ReviewType == ReviewType.OtherWorkApplyDoList) {
      //派工审核
      return _Dispatchingaudit(context, data);
    } else if (item?.ReviewType == ReviewType.CarFreightRates) {
      //外车运费审核
      return _CarFreightRates(context, data);
    } else if (item?.ReviewType == ReviewType.GuaranteedReview) {
      //保底审核
      return _GuaranteedReview(context, data);
    } else if (item?.ReviewType == ReviewType.WorkReview) {
      //加班审核
      return _WorkReviewRoute(context, data);
    } else if (item?.ReviewType == ReviewType.PercentageCheck) {
      //提成审核
      return _PercentageCheckRoute(context, data);
    } else if (item?.ReviewType == ReviewType.ContractRoyaltyRateApplyCheck) {
      //提成比例审核
      return _ContractRoyaltyRateApplyCheck(context, data, item);
    } else if (item?.ReviewType == ReviewType.LoseApplySure) {
      //报损审核
      return _LoseApplySure(context, data);
    } else if (item?.ReviewType == ReviewType.MaterialReview) {
      //五金领用审核
      return _MaterialReview(context, data);
    } else if (item?.ReviewType == ReviewType.GetPurDemandList ||
        item?.ReviewType == ReviewType.GetPurDemandListMT02 ||
        item?.ReviewType == ReviewType.GetPurDemandListMT03) {
      //请购单审核
      return _WorkOvertimeApproval4(context, data);
    } else if (item?.ReviewType == ReviewType.GetPurOrder ||
        item?.ReviewType == ReviewType.GetPurOrderMT02 ||
        item?.ReviewType == ReviewType.GetPurOrderMT03) {
      //采购单审核
      return _GetPurOrder(context, null, datas);
    } else if (item?.ReviewType == ReviewType.GetPurContract ||
        item?.ReviewType == ReviewType.GetPurContractMT02 ||
        item?.ReviewType == ReviewType.GetPurContractMT03) {
      //采购合同审核
      return _GetPurContract(context, data);
    } else if (item?.ReviewType == ReviewType.GetLogisticsContract) {
      //运输合同审核
      return _GetLogisticsContract(context, data);
    }
    //合同审核
    return _contract(context, data);
  }

  ///fixme 待审核列表（待审核事项）
  static Widget todo(BuildContext context, YwxItemNotice data) {
    if (data?.ReviewType == ReviewType.OtherWorkApplyDoList) {
      //派工审核
      return _Dispatchingaudit(context, data);
    } else if (data?.ReviewType == ReviewType.CarFreightRates) {
      //外车运费审核
      return _CarFreightRates(context, data);
    } else if (data?.ReviewType == ReviewType.GuaranteedReview) {
      //保底审核
      return _GuaranteedReview(context, data);
    } else if (data?.ReviewType == ReviewType.WorkReview) {
      //加班审核
      return _WorkReviewRoute(context, data);
    } else if (data?.ReviewType == ReviewType.PercentageCheck) {
      //提成审核
      return _PercentageCheckRoute(context, data);
    } else if (data?.ReviewType == ReviewType.LoseApplySure) {
      //报损审核
      return _LoseApplySure(context, data);
    } else if (data?.ReviewType == ReviewType.MaterialReview) {
      //五金领用审核
      return _MaterialReview(context, data);
    } else if (data?.ReviewType == ReviewType.GetPurDemandList ||
        data?.ReviewType == ReviewType.GetPurDemandListMT02 ||
        data?.ReviewType == ReviewType.GetPurDemandListMT03) {
      //请购单审核
      return _WorkOvertimeApproval4(context, data);
    } else if (data?.ReviewType == ReviewType.GetPurOrder ||
        data?.ReviewType == ReviewType.GetPurOrderMT02 ||
        data?.ReviewType == ReviewType.GetPurOrderMT03) {
      //采购单审核
      return _GetPurOrder(context, data, null);
    } else if (data?.ReviewType == ReviewType.GetPurContract ||
        data?.ReviewType == ReviewType.GetPurContractMT02 ||
        data?.ReviewType == ReviewType.GetPurContractMT03) {
      //采购合同审核
      return _GetPurContract(context, data);
    } else if (data?.ReviewType == ReviewType.GetLogisticsContract) {
      //运输合同审核
      return _GetLogisticsContract(context, data);
    }

    List<Widget> children = [];
    //合同外部编号，数据没有返回
    //Widget OutCode = _text(AppStrings.of(context).OutCode, data.OutCode);
    if (StringUtils.isNotEmpty(data.ProjectName)) {
      //项目名称
      Widget ProjectName =
          _text(AppStrings.of(context).ProjectName, data.ProjectName);
      children.add(ProjectName);
    }
    if (StringUtils.isNotEmpty(data.CustomerName)) {
      //客户名称
      Widget CustomerName =
          _text(AppStrings.of(context).CustomerName, data.CustomerName);
      children.add(CustomerName);
    }
    if (StringUtils.isNotEmpty(data.SalesmanName)) {
      //销售经理
      Widget SalesmanName =
          _text(AppStrings.of(context).SalesmanName, data.SalesmanName);
      children.add(SalesmanName);
    }
    if (StringUtils.isNotEmpty(data.MerchandiserName)) {
      //客服经理
      Widget MerchandiserName =
          _text(AppStrings.of(context).MerchandiserName, data.MerchandiserName);
      children.add(MerchandiserName);
    }
    if (StringUtils.isNotEmpty(data.InsertDatetime)) {
      //提交日期
      Widget InsertDatetime = _text(
          AppStrings.of(context).InsertDatetime, data.InsertDatetime,
          last: true);
      children.add(InsertDatetime);
    }
    return _wrap(children);
  }

  //合同审核
  static Widget _contract(BuildContext context, ContractCopyInfo data) {
    //合同外部编号，数据没有返回
    //Widget OutCode = _text(AppStrings.of(context).OutCode, data.OutCode);
    //项目名称
    Widget ProjectName =
        _text(AppStrings.of(context).ProjectName, data.ProjectName);
    //客户名称
    Widget CustomerName =
        _text(AppStrings.of(context).CustomerName, data.CustomerName);
    //销售经理
    Widget SalesmanName =
        _text(AppStrings.of(context).SalesmanName, data.SalesmanName);
    //客服经理
    Widget MerchandiserName =
        _text(AppStrings.of(context).MerchandiserName, data.MerchandiserName);
    //提交日期
    Widget InsertDatetime = _text(
        AppStrings.of(context).InsertDatetime, data.InsertDatetime,
        last: true);
    return _wrap([
      // OutCode,
      ProjectName,
      CustomerName,
      SalesmanName,
      MerchandiserName,
      InsertDatetime
    ]);
  }

  //订单审核
  static Widget _order(BuildContext context, ContractCopyInfo data) {
    //下单方式
    Widget OrderFromType =
        _text(AppStrings.of(context).OrderFromType, data.OrderFromTypeName);
    //订单外部编号
    Widget OrderOutCode =
        _text(AppStrings.of(context).OrderOutCode, data.OrderOutCode);
    //批次号
    Widget PoCode = _text(AppStrings.of(context).PoCode, data.PoCode);
    //项目名称
    Widget ProjectName =
        _text(AppStrings.of(context).ProjectName, data.ProjectName);
    //产品名称
    Widget ProductName =
        _text(AppStrings.of(context).ProductName, data.ProductName);
    //客户名称
    Widget CustomerName =
        _text(AppStrings.of(context).CustomerName, data.CustomerName);
    //片数
    Widget Num = _text(AppStrings.of(context).NumOfPieces, data.Num);
    //面积
    Widget Area = _text(AppStrings.of(context).Area, data.Area);
    //实际面积
    Widget OrdersTrueSqm =
        _text(AppStrings.of(context).OrdersTrueSqm, data.OrdersTrueSqm);
    //合同编号
    Widget ContractCode =
        _text(AppStrings.of(context).ContractCode, data.ContractCode);
    //合同外部编号
    Widget OutCode = _text(AppStrings.of(context).OutCode, data.OutCode);
    //销售经理
    Widget SalesmanName =
        _text(AppStrings.of(context).SalesmanName, data.SalesmanName);
    //客服经理
    Widget MerchandiserName = _text(
        AppStrings.of(context).MerchandiserName, data.MerchandiserName,
        last: true);
    //提交日期，数据没有返回
    // Widget InsertDatetime =
    //     _text(AppStrings.of(context).InsertDatetime, data.InsertDatetime,last: true);
    return _wrap([
      OrderFromType,
      OrderOutCode,
      PoCode,
      ProjectName,
      ProductName,
      CustomerName,
      Num,
      Area,
      OrdersTrueSqm,
      ContractCode,
      OutCode,
      SalesmanName,
      MerchandiserName,
      // InsertDatetime
    ]);
  }

  //送货地址审核
  static Widget _auditaddress(BuildContext context, ContractCopyInfo data) {
    //合同编号
    Widget ContractCode =
        _text(AppStrings.of(context).ContractCode, data.ContractCode);
    //合同外部编号
    Widget OutCode = _text(AppStrings.of(context).OutCode, data.OutCode);
    //项目名称
    Widget ProjectName =
        _text(AppStrings.of(context).ProjectName, data.ProjectName);
    // //产品名称；送货地址没有产品名称。
    // Widget ProductName =
    //     _text(AppStrings.of(context).ProductName, data.ProductName);
    //客户名称
    Widget CustomerName =
        _text(AppStrings.of(context).CustomerName, data.CustomerName);
    //申请人
    Widget PersonName = _text(
      AppStrings.of(context).PersonName,
      data.PersonName,
    );
    //申请日期
    Widget AddDate =
        _text(AppStrings.of(context).AddDate5, data.AddDate, last: true);
    //提交日期，数据没有返回
    // Widget InsertDatetime =
    //     _text(AppStrings.of(context).InsertDatetime, data.InsertDatetime,last: true);
    return _wrap([
      ContractCode,
      OutCode,
      ProjectName,
      // ProductName,
      CustomerName,
      PersonName,
      AddDate
    ]);
  }

  //合同特殊设置审核
  static Widget _contractOem(BuildContext context, ContractCopyInfo data) {
    //合同编号
    Widget ContractCode =
        _text(AppStrings.of(context).ContractCode, data.ContractCode);
    //项目名称
    Widget ProjectName =
        _text(AppStrings.of(context).ProjectName, data.ProjectName);
    //产品名称
    Widget ProductName =
        _text(AppStrings.of(context).ProductName, data.ProductName);
    //客户名称
    Widget CustomerName =
        _text(AppStrings.of(context).CustomerName, data.CustomerName);
    //销售公司
    Widget CompanyName =
        _text(AppStrings.of(context).CompanyName, data.CompanyName);
    //申请人
    Widget PersonName = _text(
      AppStrings.of(context).PersonName,
      data.PersonName,
    );
    //申请时间
    Widget AddDate =
        _text(AppStrings.of(context).AddDate, data.AddDate, last: true);
    //提交日期，数据没有返回
    // Widget InsertDatetime =
    //     _text(AppStrings.of(context).InsertDatetime, data.InsertDatetime,last: true);
    return _wrap([
      ContractCode,
      ProjectName,
      ProductName,
      CustomerName,
      CompanyName,
      PersonName,
      AddDate
    ]);
  }

  //冻结解冻审核
  static Widget _orderDJchek(BuildContext context, ContractCopyInfo data) {
    //订单外部编号
    Widget OrderOutCode =
        _text(AppStrings.of(context).OrderOutCode, data.OrderOutCode);
    //项目名称
    Widget ProjectName =
        _text(AppStrings.of(context).ProjectName, data.ProjectName);
    //客户名称
    Widget CustomerName =
        _text(AppStrings.of(context).CustomerName, data.CustomerName);
    //合同编号
    Widget ContractCode =
        _text(AppStrings.of(context).ContractCode, data.ContractCode);
    //合同外部编号
    Widget OutCode = _text(AppStrings.of(context).OutCode, data.OutCode);
    //订单状态
    Widget OrderTypeName =
        _text(AppStrings.of(context).OrderTypeName, data.OrderTypeName);
    //申请人
    Widget PersonName = _text(
      AppStrings.of(context).PersonName,
      data.PersonName,
    );
    //申请时间
    Widget AddDate =
        _text(AppStrings.of(context).AddDate, data.AddDate, last: true);
    return _wrap([
      OrderOutCode,
      ProjectName,
      CustomerName,
      ContractCode,
      OutCode,
      OrderTypeName,
      PersonName,
      AddDate
    ]);
  }

  //工厂更换审核
  static Widget _ordersChangeFactory(
      BuildContext context, ContractCopyInfo data) {
    //项目名称
    Widget ProjectName =
        _text(AppStrings.of(context).ProjectName, data.ProjectName);
    //客户名称
    Widget CustomerName =
        _text(AppStrings.of(context).CustomerName, data.CustomerName);
    //合同编号
    Widget ContractCode =
        _text(AppStrings.of(context).ContractCode, data.ContractCode);
    //合同外部编号
    Widget OutCode = _text(AppStrings.of(context).OutCode, data.OutCode);
    //订单状态
    Widget OrderTypeName =
        _text(AppStrings.of(context).OrderTypeName, data.OrderTypeName);
    //申请人
    Widget PersonName = _text(
      AppStrings.of(context).PersonName,
      data.PersonName,
    );
    //申请时间
    Widget AddDate =
        _text(AppStrings.of(context).AddDate, data.AddDate, last: true);
    return _wrap([
      ProjectName,
      CustomerName,
      ContractCode,
      OutCode,
      OrderTypeName,
      PersonName,
      AddDate
    ]);
  }

  //发货审核
  static Widget _deliveryNotice(BuildContext context, ContractCopyInfo data) {
    //通知日期
    Widget NoticeDatetime =
        _text(AppStrings.of(context).NoticeDatetime, data.NoticeDatetime);
    //通知发货日期
    Widget DeliveryDatetime =
        _text(AppStrings.of(context).DeliveryDatetime, data.DeliveryDatetime);
    //跟单员
    Widget MerchandiserName2 =
        _text(AppStrings.of(context).MerchandiserName2, data.MerchandiserName);
    //业务员
    Widget SalesmanName2 =
        _text(AppStrings.of(context).SalesmanName2, data.SalesmanName);
    //合同编号
    Widget ContractCode =
        _text(AppStrings.of(context).ContractCode, data.ContractCode);
    //合同外部编号
    Widget OutCode = _text(AppStrings.of(context).OutCode, data.OutCode);
    //项目名称
    Widget ProjectName =
        _text(AppStrings.of(context).ProjectName, data.ProjectName);
    //客户名称
    Widget CustomerName =
        _text(AppStrings.of(context).CustomerName, data.CustomerName);
    //单据状态
    Widget StatusName =
        _text(AppStrings.of(context).StatusName, data.StatusName);
    //制单人
    Widget PersonName2 = _text(
      AppStrings.of(context).PersonName2,
      data.PersonName,
    );
    //制单日期
    Widget AddDate2 =
        _text(AppStrings.of(context).AddDate2, data.AddDate, last: true);
    return _wrap([
      NoticeDatetime,
      DeliveryDatetime,
      MerchandiserName2,
      SalesmanName2,
      ContractCode,
      OutCode,
      ProjectName,
      CustomerName,
      StatusName,
      PersonName2,
      AddDate2
    ]);
  }

  //退货审核
  static Widget _payFreeGoodReturn(
      BuildContext context, ContractCopyInfo data) {
    //申请单号
    Widget ApplicationCode =
        _text(AppStrings.of(context).ApplicationCode, data.ApplicationCode);
    //入账日期
    Widget AddDate3 = _text(AppStrings.of(context).AddDate3, data.AddDate);
    //跟单员
    Widget MerchandiserName2 =
        _text(AppStrings.of(context).MerchandiserName2, data.MerchandiserName);
    //业务员
    Widget SalesmanName2 =
        _text(AppStrings.of(context).SalesmanName2, data.SalesmanName);
    //合同编号
    Widget ContractCode =
        _text(AppStrings.of(context).ContractCode, data.ContractCode);
    //项目名称
    Widget ProjectName =
        _text(AppStrings.of(context).ProjectName, data.ProjectName);
    //客户名称
    Widget CustomerName =
        _text(AppStrings.of(context).CustomerName, data.CustomerName);
    //申请人
    Widget PersonName = _text(
      AppStrings.of(context).PersonName,
      data.PersonName,
    );
    //退货金额
    Widget Amount =
        _text(AppStrings.of(context).Amount, data.Amount, last: true);
    return _wrap([
      ApplicationCode,
      AddDate3,
      MerchandiserName2,
      SalesmanName2,
      ContractCode,
      ProjectName,
      CustomerName,
      PersonName,
      Amount
    ]);
  }

  //开票审核
  static Widget _receiptApply(BuildContext context, ContractCopyInfo data) {
    //发票抬头
    Widget ReceiptTitle =
        _text(AppStrings.of(context).ReceiptTitle, data.ReceiptTitle);
    //发票类型
    Widget ReceiptType =
        _text(AppStrings.of(context).ReceiptType, data.ReceiptType);
    //发票金额
    Widget Amount2 = _text(AppStrings.of(context).Amount2, data.Amount);
    //合同编号
    Widget ContractCode =
        _text(AppStrings.of(context).ContractCode, data.ContractCode);
    //合同外部编号
    Widget OutCode = _text(AppStrings.of(context).OutCode, data.OutCode);
    //项目名称
    Widget ProjectName =
        _text(AppStrings.of(context).ProjectName, data.ProjectName);
    //客户名称
    Widget CustomerName =
        _text(AppStrings.of(context).CustomerName, data.CustomerName);
    //申请人
    Widget PersonName = _text(
      AppStrings.of(context).PersonName,
      data.PersonName,
    );
    //申请日期
    Widget AddDate5 =
        _text(AppStrings.of(context).AddDate5, data.AddDate, last: true);
    return _wrap([
      ReceiptTitle,
      ReceiptType,
      Amount2,
      ContractCode,
      OutCode,
      ProjectName,
      CustomerName,
      PersonName,
      AddDate5
    ]);
  }

  //确认收款
  static Widget _paynotice(BuildContext context, ContractCopyInfo data) {
    //客户名称
    Widget CustomerName =
        _text(AppStrings.of(context).CustomerName, data.CustomerName);
    //实收总额
    Widget Amount3 = _text(AppStrings.of(context).Amount3, data.Amount);
    //通知日期
    Widget AddDate6 =
        _text(AppStrings.of(context).AddDate6, data.AddDate, last: true);
    return _wrap([CustomerName, Amount3, AddDate6]);
  }

  //免款审核
  static Widget _payFree(BuildContext context, ContractCopyInfo data) {
    //免款类型
    Widget FreeType = _text(AppStrings.of(context).FreeType, data.FreeType);
    // //申请单号
    // Widget ApplicationCode =
    //     _text(AppStrings.of(context).ApplicationCode, data.ApplicationCode);
    //入账日期
    Widget AddDate3 = _text(AppStrings.of(context).AddDate3, data.AddDate);
    //跟单员
    Widget MerchandiserName2 =
        _text(AppStrings.of(context).MerchandiserName2, data.MerchandiserName);
    //业务员
    Widget SalesmanName2 =
        _text(AppStrings.of(context).SalesmanName2, data.SalesmanName);
    //合同编号
    Widget ContractCode =
        _text(AppStrings.of(context).ContractCode, data.ContractCode);
    //项目名称
    Widget ProjectName =
        _text(AppStrings.of(context).ProjectName, data.ProjectName);
    //客户名称
    Widget CustomerName =
        _text(AppStrings.of(context).CustomerName, data.CustomerName);
    //申请人
    Widget PersonName = _text(
      AppStrings.of(context).PersonName,
      data.PersonName,
    );
    //免款金额
    Widget Amount4 =
        _text(AppStrings.of(context).Amount4, data.Amount, last: true);
    return _wrap([
      FreeType,
      // ApplicationCode,
      AddDate3,
      MerchandiserName2,
      SalesmanName2,
      ContractCode,
      ProjectName,
      CustomerName,
      PersonName,
      Amount4
    ]);
  }

  //派工审核
  static Widget _Dispatchingaudit(BuildContext context, ContractCopyInfo data) {
    // //申请类型
    // Widget ApplicationTypeName = _text(
    //     AppStrings.of(context).ApplicationTypeName, data.ApplicationTypeName);
    //分配类型；申请类型 改为分配类型
    Widget ApplicationTypeName = _text(
        AppStrings.of(context).ApplicationTypeName2, data.ApplicationTypeName);
    //派工类型
    Widget DispatchTypeName =
        _text(AppStrings.of(context).Dispatchtype, data.DispatchTypeName);
    //申请班组
    Widget ApplicationClassName = _text(
        AppStrings.of(context).ApplicationClassName, data.ApplicationClassName);
    //申请日期
    Widget AddDate5 = _text(AppStrings.of(context).AddDate5, data.AddDate);
    //班次开始时间
    Widget OnWorkTime =
        _text(AppStrings.of(context).OnWorkTime, data.OnWorkTime);
    //班次结束时间
    Widget OffWorkTime =
        _text(AppStrings.of(context).OffWorkTime, data.OffWorkTime);
    //申请金额
    Widget Amount5 = _text(AppStrings.of(context).Amount5, data.Amount);
    //申请工时
    Widget WorkingHours =
        _text(AppStrings.of(context).WorkingHours, data.WorkingHours);
    //申请人
    Widget PersonName =
        _text(AppStrings.of(context).PersonName, data.PersonName, last: true);
    return _wrap([
      ApplicationTypeName,
      DispatchTypeName,
      ApplicationClassName,
      AddDate5,
      OnWorkTime,
      OffWorkTime,
      Amount5,
      WorkingHours,
      PersonName,
    ]);
  }

  //外车运费审核
  static Widget _CarFreightRates(BuildContext context, ContractCopyInfo data) {
    //开始日期
    Widget OnWorkTime3 =
        _text(AppStrings.of(context).OnWorkTime3, data.OnWorkTime);
    //截止日期
    Widget OffWorkTime3 =
        _text(AppStrings.of(context).OffWorkTime3, data.OffWorkTime);
    //姓名
    Widget TheName = _text(AppStrings.of(context).TheName, data.TheName);
    //运费总额
    Widget Amount8 = _text(AppStrings.of(context).Amount8, data.Amount);
    //上报人
    Widget PersonName5 = _text(
      AppStrings.of(context).PersonName5,
      data.PersonName,
    );
    //上报日期
    Widget AddDate9 =
        _text(AppStrings.of(context).AddDate9, data.AddDate, last: true);
    return _wrap(
        [OnWorkTime3, OffWorkTime3, TheName, Amount8, PersonName5, AddDate9]);
  }

  //保底审核
  static Widget _GuaranteedReview(BuildContext context, ContractCopyInfo data) {
    //申请类型
    Widget ApplicationTypeName = _text(
        AppStrings.of(context).ApplicationTypeName, data.ApplicationTypeName);
    //申请员工
    Widget PersonName4 = _text(
      AppStrings.of(context).PersonName4,
      data.PersonName,
    );
    //申请日期
    Widget AddDate5 = _text(AppStrings.of(context).AddDate5, data.AddDate);
    //班次开始时间
    Widget OnWorkTime =
        _text(AppStrings.of(context).OnWorkTime, data.OnWorkTime);
    //班次结束时间
    Widget OffWorkTime =
        _text(AppStrings.of(context).OffWorkTime, data.OffWorkTime);
    //申请保底金额
    Widget Amount11 = _text(AppStrings.of(context).Amount11, data.Amount);
    //保底所需工时
    Widget WorkingHours2 = _text(
        AppStrings.of(context).WorkingHours2, data.WorkingHours,
        last: true);
    return _wrap([
      ApplicationTypeName,
      PersonName4,
      AddDate5,
      OnWorkTime,
      OffWorkTime,
      Amount11,
      WorkingHours2,
    ]);
  }

  //加班审核
  static Widget _WorkReviewRoute(BuildContext context, ContractCopyInfo data) {
    //姓名
    Widget TheName = _text(AppStrings.of(context).TheName, data.TheName);
    //性别
    Widget Gender = _text(
      AppStrings.of(context).Gender,
      data.Gender,
    );
    //电话
    Widget Tel = _text(AppStrings.of(context).Tel, data.Telephone);
    //手机
    Widget MobilePhone2 =
        _text(AppStrings.of(context).MobilePhone2, data.MobilePhone);
    //员工性质
    Widget EmployeesNature =
        _text(AppStrings.of(context).EmployeesNature, data.EmployeesNature);
    //员工状态
    Widget EmployeesState =
        _text(AppStrings.of(context).EmployeesState, data.EmployeesState);
    //待审核数量
    Widget ToAuditNumber =
        _text(AppStrings.of(context).ToAuditNumber, data.ToAuditNumber);
    //总加班时长(分钟)
    Widget OvertimeHours = _text(
        AppStrings.of(context).OvertimeHours, data.OvertimeHours,
        last: true);
    return _wrap([
      TheName,
      Gender,
      Tel,
      MobilePhone2,
      EmployeesNature,
      EmployeesState,
      ToAuditNumber,
      OvertimeHours
    ]);
  }

  //提成审核
  static Widget _PercentageCheckRoute(
      BuildContext context, ContractCopyInfo data) {
    //人员类型
    Widget manType_ = _text(AppStrings.of(context).manType_, data.manType);
    //提成类型
    Widget payType_ = _text(
      AppStrings.of(context).payType_,
      data.payType,
    );
    //开始日期
    Widget beginDatetime_ =
        _text(AppStrings.of(context).beginDatetime_, data.beginDatetime);
    //截止日期
    Widget endDatetime_ =
        _text(AppStrings.of(context).endDatetime_, data.endDatetime);
    //姓名
    Widget merchandiserSalesname_ = _text(
        AppStrings.of(context).merchandiserSalesname_,
        data.merchandiserSalesname);
    //收款金额
    Widget amount1_ = _text(AppStrings.of(context).amount1_, data.amount1);
    //提成金额
    Widget amount2_ = _text(AppStrings.of(context).amount2_, data.amount2);
    //结存金额
    Widget amount3_ =
        _text(AppStrings.of(context).amount3_, data.amount3, last: true);
    //上报金额
    Widget amount4_ =
        _text(AppStrings.of(context).amount4_, data.amount4, last: true);
    //上报人
    Widget createrName_ = _text(
        AppStrings.of(context).createrName_, data.createrName,
        last: true);
    //上报日期
    Widget createDateTime_ = _text(
        AppStrings.of(context).createDateTime_, data.createDateTime,
        last: true);
    return _wrap([
      manType_,
      payType_,
      beginDatetime_,
      endDatetime_,
      merchandiserSalesname_,
      amount1_,
      amount2_,
      amount3_,
      amount4_,
      createrName_,
      createDateTime_
    ]);
  }

  //提成比例审核
  static Widget _ContractRoyaltyRateApplyCheck(
      BuildContext context, ContractCopyInfo data, YwxItem? item) {
    ///合同编号
    Widget ContractCode =
        _text(AppStrings.of(context).ContractCode, data.ContractCode);

    ///合同外部编号，数据没有返回
    Widget OutCode = _text(AppStrings.of(context).OutCode, data.OutCode);
    //项目名称
    Widget ProjectName =
        _text(AppStrings.of(context).ProjectName, data.ProjectName);
    //客户名称
    Widget CustomerName =
        _text(AppStrings.of(context).CustomerName, data.CustomerName);
    Widget MerchandiserRoyaltyRate = AppUi.getEmptyView();
    Widget SalesmanRoyaltyRate = AppUi.getEmptyView();
    if (item?.changerecord ?? false) {
      //更改记录
      //业务员比例
      MerchandiserRoyaltyRate = _text(
          AppStrings.of(context).MerchandiserRoyaltyRate,
          data.SalesmanRoyaltyRate);
      //客服比例
      SalesmanRoyaltyRate = _text(AppStrings.of(context).SalesmanRoyaltyRate,
          data.MerchandiserRoyaltyRate);
    }

    //销售经理
    Widget SalesmanName =
        _text(AppStrings.of(context).SalesmanName, data.SalesmanName);
    //客服经理
    Widget MerchandiserName =
        _text(AppStrings.of(context).MerchandiserName, data.MerchandiserName);
    //申请人
    Widget ApplyName = _text(AppStrings.of(context).ApplyName, data.ApplyName);
    //提交日期
    Widget InsertDatetime = _text(
        AppStrings.of(context).InsertDatetime, data.InsertDatetime,
        last: true);
    return _wrap([
      ContractCode,
      OutCode,
      ProjectName,
      CustomerName,
      MerchandiserRoyaltyRate,
      SalesmanRoyaltyRate,
      SalesmanName,
      MerchandiserName,
      ApplyName,
      InsertDatetime
    ]);
  }

  //报损审核
  static Widget _LoseApplySure(BuildContext context, ContractCopyInfo data) {
    //申请单号
    Widget ApplicationCode =
        _text(AppStrings.of(context).ApplicationCode, data.Applicationcode);
    //申请日期
    Widget Applicationdatetime = _text(
        AppStrings.of(context).Applicationdatetime,
        data.getApplicationdatetime());
    //跟单员
    Widget MerchandiserName2 =
        _text(AppStrings.of(context).MerchandiserName2, data.MerchandiserName);
    //业务员
    Widget SalesmanName2 =
        _text(AppStrings.of(context).SalesmanName2, data.SalesmanName);
    //合同编号
    Widget ContractCode =
        _text(AppStrings.of(context).ContractCode, data.ContractCode);
    //项目名称
    Widget ProjectName =
        _text(AppStrings.of(context).ProjectName, data.ProjectName);
    //客户名称
    Widget CustomerName =
        _text(AppStrings.of(context).CustomerName, data.CustomerName);
    //申请人
    Widget PersonName = _text(
      AppStrings.of(context).PersonName,
      data.ApprovalName,
    );
    //报损金额
    Widget Amount =
        _text(AppStrings.of(context).Acount2, data.Amount, last: true);
    return _wrap([
      ApplicationCode,
      Applicationdatetime,
      MerchandiserName2,
      SalesmanName2,
      ContractCode,
      ProjectName,
      CustomerName,
      PersonName,
      Amount
    ]);
  }

  //五金领用审核
  static Widget _MaterialReview(BuildContext context, ContractCopyInfo data) {
    //领料单号
    Widget PickCode = _text(AppStrings.of(context).PickCode, data.PickCode);
    //申请时间
    Widget Applicationdatetime =
        _text(AppStrings.of(context).AddDate, data.AddDate);
    //申请人
    Widget UserPersonName = _text(
        AppStrings.of(context).UserPersonName, data.UserPersonName,
        last: true);
    return _wrap([
      PickCode,
      Applicationdatetime,
      UserPersonName,
    ]);
  }

  //请购单审核
  static Widget _WorkOvertimeApproval4(
      BuildContext context, ContractCopyInfo materialInfo) {
    if (materialInfo.PurDemandList == null ||
        materialInfo.PurDemandList!.length <= 0) {
      return AppUi.getEmptyView();
    }
    if (materialInfo.PurDemandList!.length > 1) {
      List<Widget> allChildren = [];
      // //请购单号
      Widget PurchaseOrder = _text(
          AppStrings.of(context).PurchaseOrderNumber, materialInfo.PurCode,
          last: true, isCopy: true);
      //children.add(PurchaseOrder);
      allChildren.add(PurchaseOrder);
      var SerialNumber = 1;
      materialInfo.PurDemandList?.forEach((element) {
        var data = element;
        allChildren.add(_wrap(_WorkOvertimeApproval4Children(
            context, materialInfo, data, false, SerialNumber)));
        SerialNumber++;
      });
      return _wrap(allChildren);
    } else {
      var data = materialInfo.PurDemandList![0];
      return _wrap(
          _WorkOvertimeApproval4Children(context, materialInfo, data, true, 0));
    }
  }

  static List<Widget> _WorkOvertimeApproval4Children(
      BuildContext context,
      ContractCopyInfo materialInfo,
      PurDemand data,
      bool hasPur,
      int SerialNumber) {
    List<Widget> children = [];
    if (hasPur) {
      // //请购单号
      Widget PurchaseOrder = _text(
          AppStrings.of(context).PurchaseOrderNumber, materialInfo.PurCode,
          isCopy: true);
      children.add(PurchaseOrder);
    }
    var ser = "";
    if (SerialNumber > 0) {
      ser = "$SerialNumber.";
    }
    //物料类型
    Widget MaterialType = _text(ser + AppStrings.of(context).TypeOfMaterial,
        data.getMaterialTypeName(context));
    children.add(MaterialType);
    //物料编码
    Widget MaterialCode =
        _text(AppStrings.of(context).MaterialCode, data.MaterialCode);
    children.add(MaterialCode);
    //物料名称
    Widget MaterialName =
        _text(AppStrings.of(context).MaterialName3, data.MaterialName);
    children.add(MaterialName);
    //品牌
    Widget Brand = _text(AppStrings.of(context).Brand, data.ManufacturerName);
    children.add(Brand);
    //供应商
    Widget SupplierName =
        _text(AppStrings.of(context).SupplierName, materialInfo.SupplierName);
    children.add(SupplierName);
    //规格
    Widget Specifications = _text(
        AppStrings.of(context).Specifications, "${data.Width}*${data.Height}");
    children.add(Specifications);
    //项目名称
    Widget ProjectName =
        _text(AppStrings.of(context).ProjectName, materialInfo.ProjectName);
    children.add(ProjectName);
    //创建人
    Widget Founder =
        _text(AppStrings.of(context).Founder, materialInfo.CreaterName);
    children.add(Founder);
    //采购申请日期
    Widget DateRequest = _text(
        AppStrings.of(context).DateRequest2, materialInfo.getPurStartDate());
    children.add(DateRequest);
    //采购要货日期
    Widget DatePurchase = _text(
        AppStrings.of(context).PurchaseDate, materialInfo.getPurEndDate2(),
        last: true);
    children.add(DatePurchase);
    var inday = materialInfo.distancePurEndDateTime(); //超期多少天
    if (inday > 0) {
      var str = AppStrings.of(context).daysoverdue(inday);
      var text = Text(
        str,
        style: AppStyle.textStyleWithCardWhite(),
      );
      var contanin = Container(
        child: text,
        color: Colors.red,
      );
      children.add(contanin);
    }
    return children;
  }

  ///采购单审核
  static Widget _GetPurOrder(BuildContext context, ContractCopyInfo? copyInfo,
      List<ContractCopyInfo>? datas) {
    // print("===============================$copyInfo\t$datas");
    if (copyInfo != null && copyInfo.PurOrderList != null && datas == null) {
      datas = copyInfo.PurOrderList;
    }
    if (datas == null || datas.length <= 0) {
      return AppUi.getEmptyView();
    }
    var data = datas[0];
    if (datas!.length > 1) {
      List<Widget> allChildren = [];
      // //采购单号
      Widget PurchaseOrder = _text(
          AppStrings.of(context).PurOrderCode, data.PurOrderCode,
          last: true, isCopy: true);
      //children.add(PurchaseOrder);
      allChildren.add(PurchaseOrder);
      var SerialNumber = 1;
      datas?.forEach((element) {
        var data = element;
        allChildren.add(
            _wrap(_GetPurOrderChildren(context, data, false, SerialNumber)));
        SerialNumber++;
      });
      return _wrap(allChildren);
    } else {
      return _wrap(_GetPurOrderChildren(context, data, true, 0));
    }
    // return _wrap(_GetPurOrderChildren(context, materialInfo, true, 0));
  }

  static List<Widget> _GetPurOrderChildren(BuildContext context,
      ContractCopyInfo materialInfo, bool hasPur, int SerialNumber) {
    List<Widget> children = [];
    if (hasPur) {
      //采购单号
      Widget PurchaseOrder = _text(
          AppStrings.of(context).PurOrderCode, materialInfo.PurOrderCode,
          isCopy: true);
      children.add(PurchaseOrder);
    }
    var ser = "";
    if (SerialNumber > 0) {
      ser = "$SerialNumber.";
    }
    //请购单号
    Widget PurchaseOrder = _text(
        ser + AppStrings.of(context).PurchaseOrderNumber, materialInfo.PurCode,
        isCopy: true);
    children.add(PurchaseOrder);
    //物料类型
    Widget MaterialType = _text(AppStrings.of(context).TypeOfMaterial,
        materialInfo.getMaterialTypeName(context));
    children.add(MaterialType);
    //物料编码
    Widget MaterialCode =
        _text(AppStrings.of(context).MaterialCode, materialInfo.MaterialCode);
    children.add(MaterialCode);
    //物料名称
    Widget MaterialName =
        _text(AppStrings.of(context).MaterialName3, materialInfo.MaterialName);
    children.add(MaterialName);
    //品牌
    Widget Brand =
        _text(AppStrings.of(context).Brand, materialInfo.ManufacturerName);
    children.add(Brand);
    //供应商
    Widget SupplierName =
        _text(AppStrings.of(context).SupplierName, materialInfo.SupplierName);
    children.add(SupplierName);
    //规格
    Widget Specifications =
        _text(AppStrings.of(context).Specifications, "${materialInfo.Size}");
    children.add(Specifications);
    //项目名称
    Widget ProjectName =
        _text(AppStrings.of(context).ProjectName, materialInfo.ProjectName);
    children.add(ProjectName);
    //是否绑定
    Widget Bindornot =
        _text(AppStrings.of(context).Bindornot, materialInfo.getBind(context));
    children.add(Bindornot);
    //创建人
    Widget Founder = _text(
        AppStrings.of(context).Founder, materialInfo.CreaterName,
        last: true);
    children.add(Founder);
    // //采购申请日期
    // Widget DateRequest = _text(
    //     AppStrings.of(context).DateRequest2, materialInfo.getPurStartDate());
    // children.add(DateRequest);
    // //采购要货日期
    // Widget DatePurchase = _text(
    //     AppStrings.of(context).PurchaseDate, materialInfo.getPurEndDate2(),
    //     last: true);
    // children.add(DatePurchase);
    // var inday = materialInfo.distancePurEndDateTime(); //超期多少天
    // if (inday > 0) {
    //   var str = AppStrings.of(context).daysoverdue(inday);
    //   var text = Text(
    //     str,
    //     style: AppStyle.textStyleWithCardWhite(),
    //   );
    //   var contanin = Container(
    //     child: text,
    //     color: Colors.red,
    //   );
    //   children.add(contanin);
    // }
    return children;
  }

  ///采购合同审核
  static Widget _GetPurContract(BuildContext context, ContractCopyInfo data) {
    //采购合同号
    Widget PurContractCode = _text(
        AppStrings.of(context).PurContractCode, data.PurContractCode,
        isCopy: true);
    //子合同编号
    Widget PurBodyCode = _text(
        AppStrings.of(context).PurBodyCode, data.PurBodyCode,
        isCopy: true);
    //子合同外部编号
    Widget ContractOutCode = _text(
        AppStrings.of(context).ContractOutCode, data.ContractOutCode,
        last: false, isCopy: true);
    //供应商
    Widget SupplierName = _text(
        AppStrings.of(context).SupplierName, data.SupplierName,
        last: false);
    //采购公司
    Widget CompanyName = _text(
        AppStrings.of(context).CompanyName2, data.CompanyName,
        last: false);
    //物料类型
    Widget MaterialTypeName = _text(
        AppStrings.of(context).MaterialTypeName, data.MaterialTypeName,
        last: false);
    //采购员
    Widget PersonName =
        _text(AppStrings.of(context).PersonName7, data.PersonName, last: true);
    return _wrap([
      PurContractCode,
      PurBodyCode,
      ContractOutCode,
      SupplierName,
      CompanyName,
      MaterialTypeName,
      PersonName
    ]);
  }

  ///运输合同审核
  static Widget _GetLogisticsContract(
      BuildContext context, ContractCopyInfo data) {
    //运输合同号
    Widget LContractCode = _text(
        AppStrings.of(context).LContractCode, data.LContractCode,
        isCopy: true);
    //物料类型
    Widget MaterialType = _text(
        AppStrings.of(context).MaterialType, data.MaterialType,
        isCopy: true);
    //承运商
    Widget CarrierName = _text(
        AppStrings.of(context).CarrierName, data.CarrierName,
        last: false, isCopy: true);
    //采购公司
    Widget CompanyName = _text(
        AppStrings.of(context).CompanyName2, data.CompanyName,
        last: false);
    //创建时间
    Widget CreaterDateTime = _text(
        AppStrings.of(context).CreaterDateTime2, data.getCreaterDateTime(),
        last: false);
    //创建人
    Widget PersonName =
        _text(AppStrings.of(context).PersonName8, data.PersonName, last: true);
    return _wrap([
      LContractCode,
      MaterialType,
      CarrierName,
      CompanyName,
      CreaterDateTime,
      PersonName
    ]);
  }

  //last true 不带‘/’ fals 带‘/’ 即：是否为最后一个字符
  static Widget _text(String name, String? value,
      {bool last = false, bool isCopy = false}) {
    var str = name + ":$value";
    List<InlineSpan>? children = null;
    if (!last) {
      children = [
        TextSpan(text: '/', style: AppStyle.textStyleWithEntryGrey()),
      ];
    }
    var text = Text.rich(TextSpan(
        style: AppStyle.textStyleWithEntry(), text: str, children: children));
    if (isCopy) {
      return InkWell(
        child: text,
        onTap: () {
          TextUtils.copyText(value); //文本复制
        },
      );
    } else {
      return text;
    }
    // return Text(
    //   str,
    //   style: AppStyle.textStyleWithEntry(),
    // );
  }

  //自动换行
  static Widget _wrap(List<Widget> children) {
    return Padding(
        padding: EdgeInsets.symmetric(vertical: 8),
        child: Wrap(
          alignment: WrapAlignment.start,
          children: children,
        ));
  }
}
